package com.zjjxy.mapper;

import com.zjjxy.pojo.entity.Question;
import com.zjjxy.pojo.entity.Student;
import com.zjjxy.pojo.entity.StudentAnswer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.EmptyStackException;
import java.util.List;


@Mapper
public interface TeacherMapper {


    @Insert("INSERT INTO t_question(question,type,status,is_rush,score,option_a,option_b,option_c,option_d,answer,create_time,update_time) VALUES (#{question},#{type},#{status},#{isRush},#{score},#{optionA},#{optionB},#{optionC},#{optionD},#{answer},#{createTime},#{updateTime})")
    void insert(Question question);

    @Insert("INSERT INTO t_student_answer(student_id,student_no,student_name,question_id,answer,score,time,create_time,update_time) VALUES (#{studentId},#{studentNo},#{studentName},#{questionId},#{answer},#{score},#{time},#{createTime},#{updateTime})")
    void post(StudentAnswer studentAnswer);
    @Select("SELECT  * FROM t_student_answer order by score desc limit 10")
    List<StudentAnswer> getScore();

    @Select("SELECT * FROM t_question ORDER BY RAND() LIMIT 20")
    List<Question> ranDow();

    @Select("select * from t_question where id = #{id}")
    Question getQuestionById(Integer id);

    void update(Question question);

    @Select("select * from t_student where no = #{studentNo}")
    Student getByStudentNo(int studentNo);

    @Select("select score from t_question where id = #{questionId}")
    int getScoreById(Integer questionId);

    @Select("select update_time from t_question where id = #{questionId}")
    long getUpdateTime();
}
